<script src="js/jquery.battatech.excelexport.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
        $("#btnExport").click(function () {
            $("#relatorio").btechco_excelexport({
                containerid: "relatorio"
               , datatype: $datatype.Table
            });
        });
    });
</script>
<?php

mysql_connect("localhost", "root", "usbw") or die("ERRO ".  mysql_error());
mysql_select_db("orientacao_academica")or die("ERRO ".  mysql_erro());

$q = mysql_query("SELECT * FROM disciplina");
echo "<table id='relatorio'>
        <tr>
            <td><strong>Sigla</strong></td>
            <td style='padding-left:20px;'><strong>Disciplina</strong></td>
            <td style='padding-left:20px;'><strong>Natureza</strong></td>
        </tr>
            ";
        
while($r = mysql_fetch_assoc($q))
    {
    echo "<tr><td>".utf8_encode($r["sigla"])."</td><td style='padding-left:20px;'>"
            .utf8_encode($r["disciplina"])."</td><td style='padding-left:20px;'>".utf8_encode($r["natureza"])."</td></tr>";
    }
echo "</table>";

echo "<br /><br /><a href='#' id='btnExport'>Gerar Excel</a>";